<template>
  <el-tabs class="app-container" v-model="publicState.tab" @tab-change="onTabChange">
    <el-tab-pane label="Swagger" name="swagger">
      <Swagger />
    </el-tab-pane>
    <el-tab-pane label="CSS 注入" name="cssInject">
      <CSSInject />
    </el-tab-pane>
  </el-tabs>
</template>

<script lang="ts" setup>
import { reactive } from 'vue'
import Swagger from './components/Swagger.vue'
import CSSInject from './components/CSSInject.vue'
import type { TabPaneName } from 'element-plus'

const publicState = reactive({
  tab: 'swagger'
})

chrome.storage?.local.get({ tab: publicState.tab }).then((data) => {
  Object.assign(publicState, data)
})

function onTabChange(name: TabPaneName) {
  chrome.storage?.local.set({ tab: name })
}
</script>

<style>
body {
  margin: 0;
}

.app-container {
  width: 600px;
  height: 100vh;
  min-height: 500px;
  margin: auto;
  overflow: hidden;
  box-sizing: border-box;
}

.el-tabs__nav-scroll {
  padding-left: 20px;
}

.el-tab-pane {
  max-height: calc(100vh - 55px);
  overflow-y: auto;
  padding: 0 20px;
}
</style>
